package jj.jjstudy.response;

/**
 * @ClassName: ResultUtil
 * @Description: 返回结果工具类
 * @author: moke
 * @date: 2020/3/17 10:55
 */
public class JsonData {
    public static ResponseData success(Object object){
        ResponseData responseData = new ResponseData();
        responseData.setCode(ResponseCode.SUCCESS.getCode());
        responseData.setMsg(ResponseCode.SUCCESS.getMsg());
        responseData.setData(object);
        return responseData;
    }
    public static ResponseData success(){
        return success(null);
    }
    public static ResponseData fail(Integer code, String message){
        ResponseData responseData = new ResponseData();
        responseData.setCode(code);
        responseData.setMsg(message);
        return responseData;
    }
    public static ResponseData fail(ResponseCode responseCode){
        ResponseData responseData = new ResponseData();
        responseData.setCode(responseCode.getCode());
        responseData.setMsg(responseCode.getMsg());
        return responseData;
    }



    public static ResponseData success(Object object,Long total){

        ResponseData responseData = new ResponseData();
        responseData.setCode(ResponseCode.SUCCESS.getCode());
        responseData.setMsg(ResponseCode.SUCCESS.getMsg());
        responseData.setData(object);
        responseData.setTotal(total);
        return responseData;
    }

    public static ResponseData fail(String message) {
        ResponseData responseData = new ResponseData();
        responseData.setCode(ResponseCode.OPERATE_FAIL.getCode());
        responseData.setMsg(message);
        return responseData;
    }
}
